﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections;
using System.Collections.Generic;
using BLL.Wrapper;
using DAL;
using BLL;

public partial class Right : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string SelectedType;
        string url = Request.Url.ToString();


        if (url.LastIndexOf("=") > 0)
        {
            SelectedType = Request.Params["id"].ToString();
            //SelectedType = url.Remove(0, url.LastIndexOf("=") + 1);//Response.Write(url2);
            //TypeName.Text = SelectedType;
            string SupType = getSupremeTypebyRecursion(SelectedType);
            Response.Write("正在跳转...请稍等");
            Response.Write(SupType);
            switch (SupType)
            {
                case "门":
                    Response.Redirect("Doors.aspx?id=" + SupType + "&type=" + SelectedType);
                    break;
                case "窗":
                    Response.Redirect("Windows.aspx?id=" + SupType + "&type=" + SelectedType);
                    break;
                case "地面材料":
                    Response.Redirect("Ground.aspx?id=" + SupType + "&type=" + SelectedType);
                    break;
                case "墙面材料":
                    Response.Redirect("Wall.aspx?id=" + SupType + "&type=" + SelectedType);
                    break;
                case "家具建材类":
                    Response.Redirect("Furniture.aspx?id=" + SupType + "&type=" + SelectedType);
                    break;
            }
        }
        else
        {
            Response.Write("Hello,XXX");

        }


    }

    public string getSupremeTypebyRecursion(string subName)
    {
        TypeWrapper tWrapper = new TypeWrapper();
        if (tWrapper.getLevelByName(subName) != 2)
        {

            return getSupremeTypebyRecursion(tWrapper.getParentName(subName));

        }
        else
        {
            return subName;
        }
    }
    
}
